﻿using System.Collections.Generic;
using NUnit.Framework;

namespace ExtensionMethodExtravaganza.Tests
{
	[TestFixture]
	public class IListExtensionsTests
	{
		[Test]
		public void FirstAndLastTests()
		{
			var items = new List<object> { new object(), new object(), new object() };

			Assert.AreSame(items[0], items.First());
			Assert.AreSame(items[2], items.Last());
		}

		[Test]
		public void RemoveLastTest()
		{
			var a = new object();
			var items = new List<object> { a, new object() };

			Assert.AreEqual(2, items.Count);

			items.RemoveLast();

			Assert.AreEqual(1, items.Count);
			Assert.AreSame(items[0], a);

			items.RemoveLast();

			Assert.AreEqual(0, items.Count);

			items.RemoveLast();
			Assert.AreEqual(0, items.Count);
		}
	}
}
